import pygame,rendering,time,gc
from entityManager import *
from rendering import *
from vector import vector
from enemy import *
from camera import *
screenSize = (640,480)
class App:
    def __init__(self):
        gc.enable()
        self.running = True
        self.display = None
        self.frameCount = 0
        self.Start = False
        self.eM = entityMng()
    def init(self):
        pygame.init()
        self.display = pygame.display.set_mode((640,480), pygame.HWSURFACE)
        self.running = True
        self.enemy = enemy(vector(25,25),self.display)
        self.cam = Camera(vector(0,0))
        self.y = 0
    def startGame(self):
        self.display.fill((0,0,0))
        self.Start = True
    def event(self, event):
        if event.type == pygame.QUIT:
            self.running = False
            pygame.quit()
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_w:
                self.y = self.y+1
                self.cam.setPos(vector(0,self.y))
            if event.key == pygame.K_s:
                pass
            if event.key == pygame.K_a:
                pass
            if event.key == pygame.K_d:
                pass
    def loop(self):
        pygame.display.flip()
    def cleanup(self):
        pygame.quit()
    def execute(self):
        fps = pygame.time.Clock()
        if self.init() == False:
            self.running = False
        while(self.running):
            if fps.tick(250):
                self.display.fill((0,0,0))
                for event in pygame.event.get():
                    self.event(event)
                self.eM.update()
                self.loop()
        self.cleanup()
a = App()
a.init()
a.execute()
